<?php
	
	class Time { 
		
		private $_db ;

		public function Time($db) {
			$this->_db = $db ;
		}
		
		public function insert($nome, $instituicao) {
			$new_team = array (
				'nome' => $nome,
				'instituicao' => $instituicao
			);

			$this->_db->insert('time', $new_team) ;
		}
		
		public function delete($nome) {
			// DELETE FROM time WHERE login = $nome
			$this->_db->delete('time', 'nome = \'' . $nome . '\'') ;
		}
		
		public function select_from($cols, $where) {
			
			$this->_db->setFetchMode(Zend_Db::FETCH_OBJ) ;
			$col_str = '' ;
			$len = sizeof($cols) ;
			
			for ($i = 0; $i < $len; $i++) {
				if ($i > 0)
					$col_str .= ',' ;
				$col_str .= $cols[i] ;
			}
			
			$res = $this->_db->fetchAll('SELECT ' . $col_str . ' FROM time ' . $where) ;
			return $res ;
		}
		
		public function update($array_cols, $nome) {
			$this->_db->update('time', $array_cols, 'nome = \'' . $nome . '\'') ;
		}
		
		
		
	}

?>